package com.pet.order.listener;

import com.pet.order.domain.dto.OrderCheckDTO;
import com.pet.order.service.IOrderService;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.amqp.rabbit.annotation.Exchange;
import org.springframework.amqp.rabbit.annotation.Queue;
import org.springframework.amqp.rabbit.annotation.QueueBinding;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.stereotype.Component;

import static com.pet.common.utils.RabbitConstants.*;

@Slf4j
@Component
@RequiredArgsConstructor
public class MqListener {
    private final IOrderService orderService;

    @RabbitListener(bindings = @QueueBinding(
            value = @Queue(name = ORDER_CHECK_QUEUE),
            exchange = @Exchange(name = ORDER_CHECK_EXCHANGE, delayed = "true"),
            key = ORDER_CHECK_KEY
    ))
    public void orderCheckQueue(OrderCheckDTO orderCheckDTO) {
        orderService.timeout2CheckOrder(orderCheckDTO);
    }
}
